<?php
	
namespace Home\Controller;
use Think\Controller;

//公司管理
class CompanyController extends Controller
{
	public function index()
	{
		$companyModel = M('company_manage');
		$companyArray = $companyModel
					->field('company_manage.*,company_type.company_type')
					->join('company_type on company_manage.company_type_id = company_type.id')
					->select();
		$sql = $companyModel->getLastSql();
		$this->assign('companyArray',$companyArray);
		$this->display();
	}

	public function add()
	{
		if(IS_POST)
		{
			$companyModel = M('company_manage');

            $companyArray = $companyModel->create();


            $id = $companyModel->add($companyArray);
           
            $this->redirect('index');
		}else
		{
			$companyTypeModel = M('company_type');
            $companyTypeArray = $companyTypeModel->select();
            $this->assign('companyTypeArray',$companyTypeArray);
			$this->display();
		}
	}
}